New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@kizahasi/result

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kizahasi/result

Represents a value which is either OK or error.

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
626
decreased by-30.83%
Maintainers
1
Weekly downloads
 
Created
Source

@kizahasi/result

GitHub npm version minified size CI publish

Represents a value which is either OK or error.

Installation

Run npm install @kizahasi/result or yarn add @kizahasi/result

Usage

import { Result } from '@kizahasi/result';

const okObj = Result.ok(1); // Creates an "ok" object
// const okObj: Result<number> = { isError: false, value: 1 }; // …or you can create the object like this instead
if (okObj.isError) {
    console.log(okObj.error); // This cannot happen
} else {
    console.log(okObj.value); // output: 1
}

const errorObj = Result.error('ERROR!'); // Creates an "error" object
// const errorObj: Result<ANY-VALUE-TYPE> = { isError: true, error: 'ERROR!' }; // …or you can create the object like this instead
if (errorObj.isError) {
    console.log(errorObj.error); // output: ERROR!
} else {
    console.log(errorObj.value); // This cannot happen
}

FAQs

Package last updated on 18 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc